import axios from "axios";

import { Toast } from "vant";
//toast是一个js方法 要引入才能用
const http = axios.create({
  baseURL: "https://api.it120.cc/small4",
  //这是严选商城的基本路径
  timeout: 50000,
});
http.interceptors.request.use(
  (config) => {
    Toast({
      message: "加载数据",
      icon: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F974adfffd7a70fd5658da0a248fe25370684901230190-7zipTw_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1652345933&t=226da481d83d352ca9fe66891100272c",
      duration: 0,
    });
    //大部分情况在这个地方携带token
    // config.headers.Authoration.token=localStorage.getItem("token")
    // 但是严选商城跟别人不一样 不在这里携带 而是通过请求的时候？拼接

    return config;
  },
  (err) => {
    return Promise.reject(err);
  }
);

http.interceptors.response.use(
  (res) => {
    Toast.clear();
    return res;
  },
  (err) => {
    return Promise.reject(err);
  }
);
export default http;
